package ${package}.${moduleName}.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.AllArgsConstructor;
import ${package}.${moduleName}.convert.${ClassName}Convert;
import ${package}.${moduleName}.entity.${ClassName}Entity;
import ${package}.${moduleName}.query.${ClassName}Query;
import ${package}.${moduleName}.vo.${ClassName}VO;
import ${package}.${moduleName}.form.${ClassName}Form;
import ${package}.${moduleName}.mapper.${ClassName}Mapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * ${tableComment}
 *
 * @author ${author} ${email}
 * @since ${version} ${date}
 */
@Service
@AllArgsConstructor
public class ${ClassName}Service extends ServiceImpl<${ClassName}Mapper, ${ClassName}Entity> {

    public IPage<${ClassName}VO> page(${ClassName}Query query) {
        Page<${ClassName}Query> page = new Page<>(query.getPageNo(), query.getPageSize());
        return baseMapper.selectPageList(page, query);
    }
    
    public ${ClassName}VO getDetail(Long id){
        return baseMapper.selectDetail(id);
    }

    public void save(${ClassName}Form form) {
        ${ClassName}Entity entity = ${ClassName}Convert.INSTANCE.convert(form);

        baseMapper.insert(entity);
    }

    public void update(${ClassName}Form form) {
        ${ClassName}Entity entity = ${ClassName}Convert.INSTANCE.convert(form);

        updateById(entity);
    }

    @Transactional(rollbackFor = Exception.class)
    public void delete(List<Long> idList) {
        removeByIds(idList);
    }


}